<?#//v.3.1.1
#///////////////////////////////////////////////////////
#//  COPYRIGHT 2004 Phpauction.org ALL RIGHTS RESERVED//
#///////////////////////////////////////////////////////

require('../includes/config.inc.php');
include "loggedin.inc.php";

#//Default for error message (blank)
$ERR = "&nbsp;";

if(is_array($_POST['delete']) && phpa_securepost($_POST)) {
	while(list($k,$v) = each($_POST['delete'])) {
		#//
		$query = "delete from PHPAUCTIONXL_faqs where id=$k";
		$res = @mysql_query($query);
		if(!$res) {
			print "Error: $query<BR>".mysql_error();
			exit;
		}
		@mysql_query("DELETE FROM PHPAUCTIONXL_faqs_translated WHERE id=$k");
	}
}

#// Insert new message
if($_POST['action'] == "update" && phpa_securepost($_POST)) {
	if(strlen($_POST['name']) == 0) {
		$ERR = "Site's name cannot be an empty string";
		$settings = $_POST;
	} else {
		$query = "UPDATE PHPAUCTIONXL_settings set title='".addslashes($_POST['title'])."',
											       name = '".addslashes($_POST['name'])."'";
		$res = @mysql_query($query);
		if(!$res) {
			print "Error: $query<BR>".mysql_error();
			exit;
		} else {
			$MSG = "Database updated";
			$_SESSION["MSG"]=$MSG;
			Header("Location: index.php");
			exit;
		}
	}
}

#// Get data from the database
$query = "select * from PHPAUCTIONXL_faqscategories";
$res_c = @mysql_query($query);
if(!$res_c) {
	print "Error: $query<BR>".mysql_error();
	exit;
}

?>
<HTML>
<HEAD>
<link rel='stylesheet' type='text/css' href='style.css' />
<SCRIPT Language=javascript>
function selectDelete(formObj, isInverse)  {
   for (var i=0;i < formObj.length;i++)  {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox' && fldObj.name.substring(0,6)=='delete') { 
         if(isInverse)
            fldObj.checked = (fldObj.checked) ? false : true;
         else fldObj.checked = true; 
       }
   }
}
</SCRIPT>
<link href="css/main.css" rel="stylesheet" type="text/css">
</HEAD>
<bodyleftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<FORM NAME="faq" METHOD="post" ACTION="<?=basename($_SERVER['PHP_SELF'])?>">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0" class="titulo">
        <tr> 
          <td class="icono"><img src="images/content_icon2.gif" width="28" height="27" ></td>
          <td class="breadcrumbs"><p><span><?=$MSG_25_0018?></span>&nbsp;&gt;&gt;&nbsp;<?=$MSG_5232?></p></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td align="center" valign="middle">&nbsp;</td>
  </tr>
    <tr> 
    <td align="center" valign="middle">
  <TABLE WIDTH="95%" BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="CENTER">
    <TR align=center>
      <TD BGCOLOR="#ffffff">&nbsp;</TD>
    </TR>
    <TR>
      <TD><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="CENTER" class="base" style="border:1px solid #ccc;">
          <TR>
            <TD COLSPAN="2" class=title>
                <p><?=$MSG_5229?></p>
             </TD>
          </TR>
          <TR BGCOLOR="#FFFFFF">
            <TD WIDTH="86%">&nbsp;</TD>
            <TD align=center WIDTH="14%"><INPUT TYPE="submit" NAME="Submit2" VALUE="Delete" class="action">
            </TD>
          </TR>
          <?
          while($cat = mysql_fetch_array($res_c)) {
          	$cat['category']	=	stripslashes($cat['category']);
					?>
          <TR BGCOLOR="#eeeeee">
            <TD COLSPAN="2"><B> 
             <p class="blue"> <?=$cat['category']?></p>
              </B> </B> </TD>
          </TR>
          <?
          $query = "select * from PHPAUCTIONXL_faqs where category=".$cat['id'];
          $res = @mysql_query($query);
          if(!$res) {
          	print "Error: $query<BR>".mysql_error();
          	exit;
          }
          
          #//
          while($faq = mysql_fetch_array($res)) {
          	$faq['question']=	stripslashes($faq['question']);
							?>
          <TR BGCOLOR="#eeeeee">
            <TD WIDTH="86%" BGCOLOR="#FFFFFF"><A HREF=editfaq.php?id=<?=$faq['id']?>> 
             <p class="blue"> <?=$faq['question']?></p>
               </A> </TD>
            <TD WIDTH="14%" BGCOLOR="#FFFFFF" ALIGN=CENTER><INPUT TYPE="checkbox" NAME="delete[<?=$faq['id']?>]" VALUE="<?=$faq['id']?>">
            </TD>
          </TR>
          <?
          }
          }
		?>
		<TR bgcolor=#FFFFFF>
			<TD colspan=1>&nbsp;</TD>
			<TD align=center><a href="javascript: void(0)" onClick="selectDelete(document.forms[0],1)"><?=$MSG_30_0102?></A></TD>
		</TR>
          <TR BGCOLOR="#eeeeee">
            <TD BGCOLOR="#FFFFFF" WIDTH="86%">&nbsp;</TD>
            <TD WIDTH="14%" BGCOLOR="#FFFFFF" ALIGN=CENTER><INPUT TYPE="submit" NAME="Submit" VALUE="Delete" class="action">
			<INPUT TYPE="hidden" NAME="security" VALUE="<?php echo $_SESSION['security'];?>" />
            </TD>
          </TR>
        </TABLE></TD>
    </TR>
  </TABLE>
</TD>
</TR>
</TABLE>
</FORM>
</body>